<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('咨询列表')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="type-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>类型： </label>
                            <select name="cloumnCode">
                            <option value="">所有</option>
                            <option th:each="col : ${cols}" th:text="${col.name}" th:value="${col.code}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.addnoticFull()" shiro:hasPermission="system:banner:add">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:banner:edit')}]];
    var listFlag = [[${@permission.hasPermi('system:banner:list')}]];
    var removeFlag = [[${@permission.hasPermi('system:banner:remove')}]];
    var prefix = ctx + "system/banner";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            detailUrl: prefix + "/detail/{id}",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "banner管理",
            columns: [
            {
                field: 'id',
                title: '序号'
            },
            {
                field: 'imageurl',
                title: '图片',
                sortable: false,
                formatter: function (value, row, index) {
                                return '<img src="' + value + '" style="width: 100px" onclick="previewImg(\'' + value + '\')"/>'
                            }
            },
            {
                field: 'link',
                title: '连接',
                sortable: false
            },
            {
                field: 'weight',
                title: '权重'
            },
             {
                field: 'expStart',
                title: '有效期开始时间'
            },
            {
                field: 'expEnd',
                title: '有效期结束时间'
            },
            {
                field: 'createTime',
                title: '上报时间'
            },
            {
                title: '操作',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });

    /*字典列表-详细*/
    function detail(id) {
        var url = prefix + '/detail/' + id;
        $.modal.openTab("标签数据", url);
    }

    function statusTools(row) {
		    if (row.status == 1) {
    			return '正常';
    		} else {
    			return '禁用';
    		}
		}

    function updateStatus(data){
        $.operate.get(prefix + "/status?id=" + data);
    }

    function details(data){
        $.modal.openFull("会议详情",prefix + "/detail/" + data);
    }

    function previewImg(src) {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '45%',
            skin: 'layui-layer-nobg', //没有背景色
            shadeClose: true,
            content: '<img style="width: 100%" alt="link" src="' + src + '">'
        });
    }
</script>
</body>
</html>